﻿using System.Linq.Expressions;

namespace OrderingFoot.Core
{
    /// <summary>
    /// 执行仓储
    /// </summary>
    /// <typeparam name="TEntity">实体</typeparam>
    /// <typeparam name="TKey">主键</typeparam>
    public interface IExcuteRepository<TEntity, TKey> where TEntity : IEntity<TKey>
    {
        /// <summary>
        /// 新增
        /// </summary>
        Task<TEntity> AddAsync(TEntity entity);

        /// <summary>
        /// 批量新增
        /// </summary>
        Task<bool> BulkAddAsync(IList<TEntity> entityList);

        /// <summary>
        /// 更新
        /// </summary>
        Task<TEntity> UpdateAsync(TEntity entity);

        /// <summary>
        /// 部分字段更新执行体（未跟踪），返回执行类
        /// set -> 字段更新
        /// where -> 条件
        /// execute ->最终执行
        /// </summary>
        Task<BatchUpdateBuilder<TEntity>> UpdatePartialAsync();

        /// <summary>
        /// 删除
        /// </summary>
        Task<bool> DeleteAsync(TEntity entity);

        /// <summary>
        /// 删除（未跟踪）
        /// </summary>
        Task<bool> DeleteAsync(TKey id);

        /// <summary>
        /// 删除（未跟踪）
        /// </summary>
        Task<bool> DeleteAsync(Expression<Func<TEntity, bool>> condition);
    }

    /// <summary>
    /// 快速插入仓储
    /// </summary>
    /// <typeparam name="TEntity"></typeparam>
    public interface IFastBulkRepository<TEntity> where TEntity : IEntity
    {
        /// <summary>
        /// 快速批量新增（未跟踪）
        /// </summary>
        Task<bool> FastBulkAddAsync(IList<TEntity> entityList);
    }
}
